using Volo.Abp.Domain.Entities.Auditing;

namespace Matrix.Configuration
{
    /// <summary>
    /// 配置缓存项
    /// </summary>
    public class ConfigurationCacheItem : AuditedAggregateRoot<Guid>
    {
        /// <summary>
        /// 缓存的值（序列化后的字节）
        /// </summary>
        public byte[] Value { get; set; } = null!;

        /// <summary>
        /// 过期时间
        /// </summary>
        public DateTime ExpiryTime { get; set; }

        /// <summary>
        /// 缓存键
        /// </summary>
        public string CacheKey { get; set; } = string.Empty;

        /// <summary>
        /// 配置类型
        /// </summary>
        public string ValueType { get; set; } = string.Empty;

        public ConfigurationCacheItem()
        {
            ExpiryTime = DateTime.Now.AddHours(1);
        }

        public ConfigurationCacheItem(Guid id, byte[] value, string cacheKey, string valueType) : base(id)
        {
            Value = value;
            CacheKey = cacheKey;
            ValueType = valueType;
            ExpiryTime = DateTime.Now.AddHours(1);
        }
    }
}